package com.pt.pok;

import com.pt.pok.model.PokerCommand;

/**
 * @author Roman.Ivanov@playtech.com, Andrey.Panfilov@playtech.com
 * @date: 1/23/12
 *        <p/>
 *        Command handler is responsible for conversion from protocol specific model to concrete domain model
 *        object and notify listeners
 *        <p/>
 *        P - protocol message
 */
public interface CommandHandler<P> {

    /**
     * Handle message data and notify listener of specific domain command
     * 
     * @param data protocol specific formatted message data
     * @throws GeneralProxyException in case of trouble
     */
    void handle(P data)
        throws GeneralProxyException;

    /**
     * Handle message direct with returning domain object, no listener is notified
     * 
     * @param data protocol specific formatted data
     * @return domain model object
     * @throws GeneralProxyException in case of trouble
     */
    PokerCommand handleDirect(P data)
        throws GeneralProxyException;

    /**
     * Add listener which implements all methods for handling each specific domain command
     * 
     * @param commandListener - domain command listener
     */
    void addListener(CommandListener commandListener);

    void removeListener(CommandListener commandListener);

}
